<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>部门添加</title>

<script type="text/javascript" src="./resource/js/jquery-2.0.3.js"></script>
<link rel="stylesheet" href="./resource/layui/css/layui.css">

</head>
<body>
		<div class="layui-container">
		<div class="layui-row" style="padding-top: 50px;">
		<div class="layui-col-md1"></div>
						
		<div id="div1" >
		
		<div class="layui-form-item">
		<label class="layui-form-label">部门编号</label>
		<div class="layui-input-block">
		<input type="text" name="deptid"  id="deptid" required lay-verify="required" placeholder="请输入部门编号" autocomplete="off" class="layui-input"><br>
		</div>
		</div>
		
		<div class="layui-form-item">
		<label class="layui-form-label">经理编号</label>
		<div class="layui-input-block">
		<input type="text" name="managerid"  id="managerid" required lay-verify="required" placeholder="请输入部门经理ID" autocomplete="off" class="layui-input"><br>
		</div>
		</div>
		
		<div class="layui-form-item">
		<label class="layui-form-label">部门名称</label>
		<div class="layui-input-block">
		<input type="text" name="deptname"  id="deptname" required lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input"><br>
		</div>
		</div>
		
		<div class="layui-form-item">
		<div class="layui-input-block">
		<span id="msg"></span><br>
		<button id="add" class="layui-btn layui-btn-normal">立即提交</button>
		</div>
		</div>
		
		</div>
		
		</div>
		</div>
	<script type="text/javascript">
	$(function(){
        $("#add").on('click',function (event) {
            $.ajax({
                type:"get",//请求方式
                url:"DeptServlet?op=AddDept",//请求地址
                data:{//数据接收
                "deptid":$("#deptid").val(),
                "managerid":$("#managerid").val(),
                "deptname":$("#deptname").val()
                },
                dataType:'json',//数据类型
                success: function(type) {//点击成功以后调用的函数
					console.log(type);//控制台显示type
					$('#msg').html(type);//span#msg 控制台显示type
                }
            });
        });
    });
	</script>
</body>
</html>